package com.itheima.homework;

import java.util.Scanner;

public class test07 {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        System.out.println("请输入您的身份证");
        String s = sc.next();
        test(s);

    }
    public static void test(String s){
        if(s.length() != 18){
            System.out.println("不合法");
            return;
        }
        if(s.startsWith("0")){
            System.out.println("不合法");
            return;
        }
        String s1 = s.substring(0,s.length()-1);
        for (int i = 0; i <s1.length() ; i++) {
            char c = s1.charAt(i);
            if(c<'0'||c>'9'){
                System.out.println("不合法");
                return;
            }
        }
        if (s.charAt(17)<='9'&&s.charAt(17)>='0'||s.charAt(17)=='X'){
            System.out.println("合法");
        }else {
            System.out.println("不合法");
        }
    }
}
